# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=path.py
pkgbase=mingw-w64-python2-path
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-path")
pkgver=11.5.2
pkgrel=1
pkgdesc="File system based database that uses python pickles (mingw-w64)"
url="https://pypi.org/project/path.py/"
arch=('any')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python2"
         "${MINGW_PACKAGE_PREFIX}-python2-importlib-metadata"
         "${MINGW_PACKAGE_PREFIX}-python2-backports.os")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pytest-runner"
              "${MINGW_PACKAGE_PREFIX}-python2-pytest-flake8")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/jaraco/path.py/archive/${pkgver}.tar.gz")
sha512sums=('f1beb0b2cb6426cdd5b620550e10e22169d2dbeaa658b352a0df0abbc3572347034836dd01dd4fa446cc5ebac2fe39c722da1880687128cf5cfaeccf3fdda1a1')

prepare() {
  rm -rf python2-build-${CARCH}
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

check() {
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py pytest || true
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build
  install -d ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}
  head -n 21 path.py > ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}
